﻿<%@ page pageEncoding="UTF-8"%>
<%@include file="/util/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <%@include file="../common/head.jsp"%>
        <script language="javascript" type="text/javascript">
            //保存成功的提示信息
            function showResult() {
                showResultDiv(true);
                window.setTimeout("showResultDiv(false);", 3000);
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("save_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }
             $(function(){
            $("#userForm").validate({
            	rules:{
            	"admin.name":"required",
            	"admin.telephone":"required",
            	"admin.email":{required:true,email:true}
            	},messages:{
            		"admin.name":"20长度以内的汉字、字母的组合",
            		"admin.telephone":"电话号码格式：手机或固话",
            		"admin.email":{required:"请填写Email",email:"正确的 email 格式"}
            	},errorPlacement:function(error,element) {
            		 error.appendTo(element.siblings(":last").addClass("error_msg"));
            	},success:function(label,element){
            		 	$(element).siblings(":last").removeClass("error_msg").empty();
            		 }
            });
            	$('#save').click(function(){
            	if(!$("#userForm").valid()) return;
            		var b=$("#userForm").submitForm("update",
            			"保存失败，数据并发错误！",'保存成功!',$("#save_result_info"));
            			if(b){
            				$('#save_result_info').attr("class","save_success");
            			}else{
            				$('#save_result_info').attr("class","save_fail");
            			}
            			showResult();
            	});
            });
        </script>
    <body>
        <%@include file="../common/top.jsp"%>
    
        <div id="main">            
            <!--保存操作后的提示信息：成功或者失败-->
            <div id="save_result_info" class="save_success">保存成功！</div><!--保存失败，数据并发错误！-->
            <s:form theme="simple" cssClass="main_form" id="userForm">
            			<s:hidden name="admin.id"/>
                <div class="text_info clearfix"><span>管理员账号：</span></div>
                <div class="input_info"><input type="text" readonly="readonly" class="readonly" value="${admin.code}" /></div>
                <div class="text_info clearfix"><span>角色：</span></div>
                <div class="input_info">
                    <input type="text" readonly="readonly" class="readonly width400" value="<s:property value="admin.toRoleNames()"/>" />
                </div>
                <div class="text_info clearfix"><span>姓名：</span></div>
                <div class="input_info">
                    <s:textfield name="admin.name"/>
                    <span class="required">*</span>
                    <div class="validate_msg_long"></div>
                </div>
                <div class="text_info clearfix"><span>电话：</span></div>
                <div class="input_info">
                    <s:textfield name="admin.telephone" cssClass="width200"/>
                    <div class="validate_msg_medium"></div>
                </div>
                <div class="text_info clearfix"><span>Email：</span></div>
                <div class="input_info">
                    <s:textfield name="admin.email" cssClass="width200"/>
                    <div class="validate_msg_medium"></div>
                </div>
                <div class="text_info clearfix"><span>创建时间：</span></div>
                <div class="input_info"><input type="text" readonly="readonly" class="readonly" 
                value="<s:date name="admin.enrollDate" format="yyyy/MM/dd HH:mm:ss"/>"/></div>
                <div class="button_info clearfix">
                    <input type="button" value="保存" class="btn_save" id="save" />
                </div>
            </s:form>  
        </div>
        
        <%@include file="../common/bottom.jsp"%>
    </body>
</html>
